//
//  DateBaseSingleton.m
//  UI-豆瓣项目APP
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 孙鹏. All rights reserved.
//

#import "DateBaseSingleton.h"
#import <sqlite3.h>
@implementation DateBaseSingleton

+(instancetype)shareDateBase
{
    
    static DateBaseSingleton *dateBase = nil;
    if (dateBase == nil) {
        
        dateBase = [[DateBaseSingleton alloc]init];
        
    }
    
    return dateBase;
    
}

static sqlite3 *db = nil;

-(void)openDB
{
    
    if (db != nil) {
        
        NSLog(@"数据库已经打开了");
        return;
        
    }
    

    
    NSString *sqlFile = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
    
    
    NSString *sqlPath = [sqlFile stringByAppendingPathComponent:@"activity.sqlite"];
    
    NSLog(@"路径%@",sqlPath);
    BOOL result = sqlite3_open(sqlPath.UTF8String, &db);
    if (result == SQLITE_OK) {
        
        NSLog(@"打开成功");
        
    }else
    {
        NSLog(@"打开失败");
        
    }
    
}

- (void)creatTable
{
    
    NSString *sql = @"CREATE TABLE IF NOT EXISTS DBY(number INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT ,begin_time TEXT, end_time TEXT ,category_name TEXT ,address TEXT ,content TEXT ,name TEXT ,image TEXT ,wisher_count TEXT , participant_count TEXT )";
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建表成功");
        
    }
    else
    {
        NSLog(@"创建表失败");
        
    }
    
    
    
}

- (void)insertActivity:(Activitylist *)act
{
    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO DBY(title ,begin_time ,end_time , category_name, address, content, name, image, wisher_count, participant_count)VALUES('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@')",act.title,act.begin_time,act.end_time,act.category_name,act.address,act.content,act.name,act.image,act.wisher_count,act.participant_count];
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入成功");
        
    }else{
        
        NSLog(@"插入失败");
        
    }
    
    
    
}

-(NSMutableArray *)selectActivity
{
    
    
    NSMutableArray *activityArray = [NSMutableArray array];
    
    NSString *sql = @"SELECT *FROM DBY";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        
        int number = sqlite3_column_int(stmt, 0);
        
        const unsigned char *title = sqlite3_column_text(stmt, 1);
         const unsigned char *begin_time = sqlite3_column_text(stmt, 2);
         const unsigned char *end_time = sqlite3_column_text(stmt, 3);
         const unsigned char *category_name = sqlite3_column_text(stmt, 4);
        const unsigned char *address = sqlite3_column_text(stmt, 5);
        const unsigned char *content = sqlite3_column_text(stmt, 6);
        const unsigned char *name = sqlite3_column_text(stmt, 7);
        const unsigned char *image = sqlite3_column_text(stmt, 8);
        const unsigned char *wisher_count = sqlite3_column_text(stmt, 9);
        const unsigned char *participant_count = sqlite3_column_text(stmt, 10);

        NSString *titleStr = [NSString stringWithUTF8String:(const char *)title];
        NSString *begin_timeStr = [NSString stringWithUTF8String:(const char *)begin_time];
        NSString *end_timeStr = [NSString stringWithUTF8String:(const char *)end_time];
        NSString *category_nameStr = [NSString stringWithUTF8String:(const char *)category_name];
        NSString *addressStr = [NSString stringWithUTF8String:(const char *)address];
        NSString *contentStr = [NSString stringWithUTF8String:(const char *)content];
         NSString *nameStr = [NSString stringWithUTF8String:(const char *)name];
        NSString *imageStr = [NSString stringWithUTF8String:(const char *)image];
        NSString *wisher_countStr = [NSString stringWithUTF8String:(const char *)wisher_count];
         NSString *participant_countStr = [NSString stringWithUTF8String:(const char *)participant_count];
        
        
        Activitylist *act = [[Activitylist alloc]init];
        act.title = titleStr;
        act.begin_time = begin_timeStr;
        act.end_time = end_timeStr;
        act.category_name = category_nameStr;
        act.address = addressStr;
        act.name = nameStr;
        act.content = contentStr;
        act.image = imageStr;
        act.wisher_count = wisher_countStr;
        act.participant_count = participant_countStr;

        
        [activityArray addObject:act];
    }
    
    
    return activityArray;
}

-(void)dropTable
{
    
    
    NSString *sql = @"DROP TABLE DBY";
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    if (result == SQLITE_OK) {
        
        NSLog(@"删除整张表成功");
        
    }else
    {
        
        NSLog(@"删除整张表失败");
        
    }
    
    
}

-(void)creatUserTable
{
    
    NSString *sql = @"CREATE TABLE IF NOT EXISTS USER(number INTEGER PRIMARY KEY AUTOINCREMENT,userName TEXT ,code TEXT)";
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建表成功");
        
    }
    else
    {
        NSLog(@"创建表失败");
        
    }

    
}


- (void)insertUser:(UserList *)user{
    
    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO USER(userName, code)VALUES('%@','%@')",user.userName,user.code];
    NSLog(@"code === %@",user.code);
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入成功");
        
    }else{
        
        NSLog(@"插入失败");
        
    }
    
}

-(void)dropUserTable
{
    
    
    NSString *sql = @"DROP TABLE USER";
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    if (result == SQLITE_OK) {
        
        NSLog(@"删除整张表成功");
        
    }else
    {
        
        NSLog(@"删除整张表失败");
        
    }
    
    
}

-(NSMutableArray *)selectUser
{
    
    NSMutableArray *UserArray = [NSMutableArray array];
    
    NSString *sql = @"SELECT *FROM USER";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }

    while (sqlite3_step(stmt) == SQLITE_ROW) {
    const unsigned char *userName = sqlite3_column_text(stmt, 1);
    const unsigned char *code = sqlite3_column_text(stmt, 2);

    
    NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];
    NSString *codeStr = [NSString stringWithUTF8String:(const char *)code];
    
    UserList *user = [[UserList alloc]init];
    user.userName = userNameStr;
    user.code = codeStr;
    
    [UserArray addObject:user];
    
    }
    return UserArray;
    
}

-(NSMutableArray *)selectUserName
{
    NSMutableArray *userNameArray = [NSMutableArray array];

    
    NSString *sql = @"SELECT *FROM USER";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    
    while (sqlite3_step(stmt) == SQLITE_ROW) {
    const unsigned char *userName = sqlite3_column_text(stmt, 1);
    NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];

        [userNameArray addObject:userNameStr];
    }
    return userNameArray;
    
    
}





- (void)creatActivityDetailTable
{
       NSString *sql = @"CREATE TABLE IF NOT EXISTS ActDetail(number INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT ,begin_time TEXT, end_time TEXT ,category_name TEXT ,address TEXT ,content TEXT ,name TEXT ,image TEXT ,wisher_count TEXT , participant_count TEXT,userName TEXT )";
    
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建表成功");
        
    }
    else
    {
        NSLog(@"创建表失败");
        
    }
}

- (void)insertActivityDeatail:(Activitylist *)actDetail
{

    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO ActDetail(title ,begin_time ,end_time , category_name, address, content, name, image, wisher_count, participant_count,userName)VALUES('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@')",actDetail.title,actDetail.begin_time,actDetail.end_time,actDetail.category_name,actDetail.address,actDetail.content,actDetail.name,actDetail.image,actDetail.wisher_count,actDetail.participant_count,actDetail.userName];

    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入成功");
        
    }else{
        
        NSLog(@"插入失败");
        
    }
    
}



-(NSMutableArray *)selectActivityDetail
{
    
    
    NSMutableArray *activityArray = [NSMutableArray array];
    
    NSString *sql = @"SELECT *FROM ActDetail";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        
        int number = sqlite3_column_int(stmt, 0);
        
        const unsigned char *title = sqlite3_column_text(stmt, 1);
        const unsigned char *begin_time = sqlite3_column_text(stmt, 2);
        const unsigned char *end_time = sqlite3_column_text(stmt, 3);
        const unsigned char *category_name = sqlite3_column_text(stmt, 4);
        const unsigned char *address = sqlite3_column_text(stmt, 5);
        const unsigned char *content = sqlite3_column_text(stmt, 6);
        const unsigned char *name = sqlite3_column_text(stmt, 7);
        const unsigned char *image = sqlite3_column_text(stmt, 8);
        const unsigned char *wisher_count = sqlite3_column_text(stmt, 9);
        const unsigned char *participant_count = sqlite3_column_text(stmt, 10);
        const unsigned char *userName = sqlite3_column_text(stmt, 11);

        
        NSString *titleStr = [NSString stringWithUTF8String:(const char *)title];
        NSString *begin_timeStr = [NSString stringWithUTF8String:(const char *)begin_time];
        NSString *end_timeStr = [NSString stringWithUTF8String:(const char *)end_time];
        NSString *category_nameStr = [NSString stringWithUTF8String:(const char *)category_name];
        NSString *addressStr = [NSString stringWithUTF8String:(const char *)address];
        NSString *contentStr = [NSString stringWithUTF8String:(const char *)content];
        NSString *nameStr = [NSString stringWithUTF8String:(const char *)name];
        NSString *imageStr = [NSString stringWithUTF8String:(const char *)image];
        NSString *wisher_countStr = [NSString stringWithUTF8String:(const char *)wisher_count];
        NSString *participant_countStr = [NSString stringWithUTF8String:(const char *)participant_count];
        NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];

        
        Activitylist *act = [[Activitylist alloc]init];
        
        act.title = titleStr;
        act.begin_time = begin_timeStr;
        act.end_time = end_timeStr;
        act.category_name = category_nameStr;
        act.address = addressStr;
        act.name = nameStr;
        act.content = contentStr;
        act.image = imageStr;
        act.wisher_count = wisher_countStr;
        act.participant_count = participant_countStr;
        act.userName = userNameStr;
        
        
        [activityArray addObject:act];
    }
    
    
    return activityArray;
}

- (void)deleteActivityDetail:(NSString *)title
{
    
    
    NSString *sql = [NSString stringWithFormat:@"DELETE FROM ActDetail WHERE title = '%@'",title];
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"删除成功");
        
    }else
    {
        NSLog(@"删除失败");
        
    }
}



-(NSMutableArray *)selectActivityDetailName:(NSString *)userName
{
    
    NSMutableArray *activityArray = [NSMutableArray array];
    
    NSString *sql = [NSString stringWithFormat:@"SELECT *FROM ActDetail WHERE userName = '%@'",userName] ;
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
    
    const unsigned char *title = sqlite3_column_text(stmt, 1);
    NSString *titleStr = [NSString stringWithUTF8String:(const char *)title];
    
        [activityArray addObject: titleStr];
    
    
}
    return activityArray;
}



- (void)creatMovieTable
{
    
    NSString *sql = @"CREATE TABLE IF NOT EXISTS Movie(number INTEGER PRIMARY KEY AUTOINCREMENT,movieId TEXT ,movieName TEXT, pic_url TEXT ,rating_count TEXT , runtime TEXT , release_date TEXT , genres TEXT,country TEXT,actors TEXT , plot_simple TEXT, userName TEXT)";
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建表成功");
        
    }
    else
    {
        NSLog(@"创建表失败");
        
    }
    
}

- (void)insertMovie:(Movielist *)movie{
    
    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO Movie(movieId, movieName, pic_url,userName)VALUES('%@','%@','%@','%@')",movie.movieId,movie.movieName,movie.pic_url,movie.userName];
   
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入成功");
        
    }else{
        
        NSLog(@"插入失败");
        
    }
    
}



-(NSMutableArray *)selectMovie
{
    
    NSMutableArray *movieArray = [NSMutableArray array];
    
    NSString *sql = @"SELECT *FROM Movie";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        
        const unsigned char *movieId = sqlite3_column_text(stmt, 1);
        const unsigned char *movieName = sqlite3_column_text(stmt, 2);
        const unsigned char *pic_url = sqlite3_column_text(stmt, 3);
        const unsigned char *userName = sqlite3_column_text(stmt, 11);



        NSString *movieIdStr = [NSString stringWithUTF8String:(const char *)movieId];
        NSString *movieNameStr = [NSString stringWithUTF8String:(const char *)movieName];
        NSString *pic_urlStr = [NSString stringWithUTF8String:(const char *)pic_url];
        NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];


        
        Movielist *movie = [[Movielist alloc]init];
        
        movie.movieId = movieIdStr;
        movie.movieName = movieNameStr;
        movie.pic_url = pic_urlStr;
        movie.userName = userNameStr;
      
        
        [movieArray addObject: movie];
        
        
    }
    return movieArray;
}


-(NSMutableArray *)selectMovieUserName:(NSString *)userName
{
    
    NSMutableArray *activityArray = [NSMutableArray array];
    
   NSString *sql = [NSString stringWithFormat:@"SELECT *FROM MovieUser WHERE userName = '%@'",userName] ;
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询准备成功");
        
        
    }else
    {
        NSLog(@"查询准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        
        const unsigned char *movieId = sqlite3_column_text(stmt, 1);
        const unsigned char *movieName = sqlite3_column_text(stmt, 2);
        const unsigned char *pic_url = sqlite3_column_text(stmt, 3);
        const unsigned char *userName = sqlite3_column_text(stmt, 11);
        
        
        
        NSString *movieIdStr = [NSString stringWithUTF8String:(const char *)movieId];
        NSString *movieNameStr = [NSString stringWithUTF8String:(const char *)movieName];
        NSString *pic_urlStr = [NSString stringWithUTF8String:(const char *)pic_url];
        NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];
        
        
        
        
        Movielist *movie = [[Movielist alloc]init];
        movie.movieId = movieIdStr;
        movie.movieName = movieNameStr;
        movie.pic_url = pic_urlStr;
        movie.userName = userNameStr;
        
        
        [activityArray addObject: movie];
        
        
        
    }
    return activityArray;
}



-(void)dropMovieTable
{
    
    
    NSString *sql = @"DROP TABLE Movie";
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    if (result == SQLITE_OK) {
        
        NSLog(@"删除整张表成功");
        
    }else
    {
        
        NSLog(@"删除整张表失败");
        
    }
    
    
}


- (void)creatMovieDetailTable
{
    
    NSString *sql = @"CREATE TABLE IF NOT EXISTS MovieDetail(number INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT ,rating TEXT ,rating_count TEXT , runtime TEXT , release_date TEXT , genres TEXT,country TEXT,actors TEXT , plot_simple TEXT,userName TEXT)";
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建电影详情表成功");
        
    }
    else
    {
        NSLog(@"创建电影详情表失败");
        
    }
    
}




- (void)insertMovieDetail:(Movielist *)movie{
    
    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO MovieDetail(title,rating,rating_count,runtime,release_date,genres,country,actors,plot_simple,userName)VALUES('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@')",movie.title,movie.rating,movie.rating_count,movie.runtime,movie.release_date,movie.genres,movie.country,movie.actors,movie.plot_simple,movie.userName];
    
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入电影详情成功");
        
    }else{
        
        NSLog(@"插入电影详情失败");
        
    }
    
}



-(NSMutableArray *)selectMovieDetail
{
   
    NSMutableArray *array= [NSMutableArray array];
    
    NSString *sql = @"SELECT *FROM MovieDetail";
    sqlite3_stmt *stmt = nil;
    BOOL result = sqlite3_prepare(db, sql.UTF8String, -1, &stmt, nil);
    if (result == SQLITE_OK) {
        
        NSLog(@"查询电影详情准备成功");
        
        
    }else
    {
        NSLog(@"查询电影详情准备失败");
        
    }
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        
        const unsigned char *title = sqlite3_column_text(stmt, 1);
        const unsigned char *rating = sqlite3_column_text(stmt, 2);
        const unsigned char *rating_count = sqlite3_column_text(stmt, 3);
        const unsigned char *runtime = sqlite3_column_text(stmt, 4);
        const unsigned char *release_date = sqlite3_column_text(stmt, 5);
        const unsigned char *genres = sqlite3_column_text(stmt, 6);
        const unsigned char *country = sqlite3_column_text(stmt, 7);
        const unsigned char *actors = sqlite3_column_text(stmt, 8);
        const unsigned char *plot_simple = sqlite3_column_text(stmt, 9);
        const unsigned char *userName = sqlite3_column_text(stmt, 10);

        
        
        
        NSString *titleStr = [NSString stringWithUTF8String:(const char *)title];
        NSString *ratingStr = [NSString stringWithUTF8String:(const char *)rating];
        NSString *rating_countStr = [NSString stringWithUTF8String:(const char *)rating_count];
        NSString *runtimeStr = [NSString stringWithUTF8String:(const char *)runtime];
        NSString *release_dateStr = [NSString stringWithUTF8String:(const char *)release_date];
        NSString *genresStr = [NSString stringWithUTF8String:(const char *)genres];
        NSString *countryStr = [NSString stringWithUTF8String:(const char *)country];
        NSString *actorsStr = [NSString stringWithUTF8String:(const char *)actors];
        NSString *plot_simpleStr = [NSString stringWithUTF8String:(const char *)plot_simple];
        NSString *userNameStr = [NSString stringWithUTF8String:(const char *)userName];

        
        
        Movielist *movie = [[Movielist alloc]init];
        movie.title = titleStr;
        movie.rating = ratingStr;
        movie.rating_count = rating_countStr;
        movie.runtime = runtimeStr;
        movie.release_date = release_dateStr;
        movie.genres = genresStr;
        movie.country = countryStr;
        movie.actors = actorsStr;
        movie.plot_simple = plot_simpleStr;
        movie.userName = userNameStr;
        
        
        
        
        
    }
    return array;
}
-(void)dropMovieDetailTable
{
    
    
    NSString *sql = @"DROP TABLE MovieDetail";
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    if (result == SQLITE_OK) {
        
        NSLog(@"删除电影详情整张表成功");
        
    }else
    {
        
        NSLog(@"删除电影详情整张表失败");
        
    }
    
    
}


- (void)creatMovieUserTable
{
    
    NSString *sql = @"CREATE TABLE IF NOT EXISTS MovieUser(number INTEGER PRIMARY KEY AUTOINCREMENT,movieId TEXT ,movieName TEXT, pic_url TEXT ,rating_count TEXT , runtime TEXT , release_date TEXT , genres TEXT,country TEXT,actors TEXT , plot_simple TEXT, userName TEXT)";
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"创建表成功");
        
    }
    else
    {
        NSLog(@"创建表失败");
        
    }
    
}

- (void)insertMovieUser:(Movielist *)movie{
    
    
    NSString *sql = [NSString stringWithFormat:@"INSERT INTO MovieUser(movieId, movieName, pic_url,userName)VALUES('%@','%@','%@','%@')",movie.movieId,movie.movieName,movie.pic_url,movie.userName];
    
    
    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
    
    if (result == SQLITE_OK) {
        
        NSLog(@"插入成功");
        
    }else{
        
        NSLog(@"插入失败");
        
    }
    
}

//- (void)deleteActivityDetail:(NSString *)title
//{
//    
//    
//    NSString *sql = [NSString stringWithFormat:@"DELETE FROM ActDetail WHERE title = '%@'",title];
//    
//    BOOL result = sqlite3_exec(db, sql.UTF8String, NULL, NULL, NULL);
//    
//    if (result == SQLITE_OK) {
//        
//        NSLog(@"删除成功");
//        
//    }else
//    {
//        NSLog(@"删除失败");
//        
//    }
//}




@end
